/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. **/
package com.minierp.controller;

import com.minierp.dao.OutTypeDao;
import com.minierp.err.PermissionDennyException;
import com.minierp.helper.EncCommonHelper;
import com.minierp.model.OutType;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class OutTypeMACtr extends MultiActionController {
	private OutTypeDao outTypeDao;
	private String listView;
	private String operateSuccessView;

	public ModelAndView handleList(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		if (!EncCommonHelper.checkPrivilege(request, "OUT_TYPE")) {
			throw new PermissionDennyException("Permission Denny");
		} else {
			ModelAndView mv = new ModelAndView(this.listView);
			List list = this.outTypeDao.getList(true);
			mv.addObject("list", list);
			return mv;
		}
	}

	public ModelAndView handleDelete(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		ModelAndView mv = new ModelAndView(this.operateSuccessView);
		OutType f = (OutType) this.outTypeDao.get(OutType.class,
				Long.parseLong(request.getParameter("id")));
		if (f != null) {
			f.setEnabled("N");
			this.outTypeDao.update(f);
		}

		String msg = "删除成功！";
		EncCommonHelper.setAlertMessage(request, msg);
		return mv;
	}

	public String getListView() {
		return this.listView;
	}

	public void setListView(String listView) {
		this.listView = listView;
	}

	public OutTypeDao getOutTypeDao() {
		return this.outTypeDao;
	}

	public void setOutTypeDao(OutTypeDao outTypeDao) {
		this.outTypeDao = outTypeDao;
	}

	public String getOperateSuccessView() {
		return this.operateSuccessView;
	}

	public void setOperateSuccessView(String operateSuccessView) {
		this.operateSuccessView = operateSuccessView;
	}
}